<?php

namespace Controller\Article;

class Lists extends \Controller\Base {

	public function actionIndex() {
		$this->setMenuPath('Article', 'Lists');
		// 得到文章
		$pager = new \Lib\Core\Pager();
		$pager->currentPage = $this->getInt('page', 1);
		$categoryId = $this->getInt('categoryId');
		$list = \Data\Article::instance()->getList($pager, $categoryId);
		$categoryList = \Data\Category::instance()->getAll();
		$all = \Data\Category::instance()->getLevelCategories();
		foreach ($list as &$arr) {
			$cId = $arr['CategoryId'];
			$arr['CategoryName'] = isset($categoryList[$cId]) ? $categoryList[$cId]['CategoryName'] : '';
		}
		$this->assign('all', $all);
		$this->assign('categoryId', $categoryId);
		$this->assign('list', $list);
		$this->assign('pager', $pager);
		$this->display();
	}
}